package com.jy.datapipeline.importserver.controller;

import com.jy.datapipeline.common.exception.GlobalException;
import com.jy.datapipeline.common.vo.ReturnVo;
import com.jy.datapipeline.importserver.service.ImportSubTaskService;
import org.quartz.SchedulerException;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @类名 ImportSubtaskController
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2023/4/28 11:09
 * @版本 1.0
 */
@RestController
@RequestMapping("/subtask")
public class ImportSubtaskController {

    @Resource
    private ImportSubTaskService importSubTaskService;

    @GetMapping("/query-by-page")
    public ReturnVo queryByPage(@RequestParam(defaultValue = "1") Long pageNo, @RequestParam(defaultValue = "10") Long pageSize,
                                @RequestParam String taskId, String subtaskStatus, Integer trySubtaskLoadCurrentCount) {
        return importSubTaskService.queryByPage(pageNo, pageSize, subtaskStatus, taskId, trySubtaskLoadCurrentCount);
    }

    @DeleteMapping("/deletion")
    public ReturnVo deletion(@RequestParam Long[] ids) throws GlobalException, SchedulerException {
        importSubTaskService.deleteSubTask(ids);
        return ReturnVo.ok();
    }
}
